﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class SetUpManager : MonoBehaviour {
  
    public GameObject SetUp; //设置页面
    //public GameObject SliderBGMusic; //找到背景音乐

    public AudioSource audioSource1; //背景音乐组件
    public Slider slider1; //背景音乐控制条

    public AudioSource audioSource2;  //游戏音效组件
    public Slider slider2; //游戏音效控制条

    public Button ReturnButton; //返回按钮
    public Button SetUpButton; //设置按钮

    // Use this for initialization
    void Start ()
    {
      
    }
	
	// Update is called once per frame
	void Update () {

        audioSource1.volume = slider1.value;
        audioSource2.volume = slider2.value;
    }

   /// <summary>
   /// 返回界面
   /// </summary>
    public void GoBack()
    {
        SetUp.SetActive(false);//关掉设置界面
      
        SetUpButton.gameObject.SetActive(true);//关掉设置按钮
    }
    /// <summary>
    /// 点击设置按钮
    /// </summary>
    public void OnClickSetUpButton()
    {
        
        SetUp.SetActive(true);//打开设置界面
        audioSource1 = GameObject.FindGameObjectWithTag("MainCamera").transform.GetComponent<AudioSource>();//找到背景音乐组件
        slider1 = GameObject.Find("SliderBGMusic").transform.GetComponent<Slider>();//找到背景音乐控制条

        audioSource2 = GameObject.Find("Canvas").transform.GetComponent<AudioSource>();//找到游戏音效
        slider2 = GameObject.Find("SliderGameMusic").transform.GetComponent<Slider>();//找到游戏音效控制条
        
         SetUpButton = GameObject.Find("SetUpButton").GetComponent<Button>();//找到设置按钮
        SetUpButton.gameObject.SetActive(false);//关闭设置按钮
        
        
    }

}
